package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiSetQuestions;

import java.util.List;

/**
 * Created by Administrator on 2016/5/28.
 */
public class QuestionAdapter extends BaseAdapter {


    private LayoutInflater inflater;
    private List<GetApiSetQuestions.Data> dataList;

    public QuestionAdapter(Context context, List<GetApiSetQuestions.Data> dataList) {
        inflater = LayoutInflater.from(context);
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_listview_changjianwenti,null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder.txt = (TextView) convertView.findViewById(R.id.txt_changjianwenti_listview);

            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.txt.setText(dataList.get(position).title);

        return convertView;
    }
    class ViewHolder{
        TextView txt;
    }
}
